#ifndef _NE_MIDI_TRACK_H_
#define _NE_MIDI_TRACK_H_

#include <audio/MIDI/MIDIChannel.h>
#include <audio/MIDI/MIDIEvent.h>
#include <audio/MIDI/MIDIInstrument.h>

namespace ne
{
    class NEAPI MIDITrack
    {
        public:
            MIDITrack(const std::string &name="MIDI Track");

            void setName(const std::string &name);
            const std::string& getName() const;

            void setChannel(const byte channel);
            byte getChannel() const;

            void setInstrument(const byte instrument);
            byte getInstrument() const;

            bool hasNotes() const;

            MIDIEvent* getEvent(const double ticks) const;

            // Use absolute ticks
            MIDIEventListIterator insertEvent(MIDIEvent *pEvent);
            // Use related ticks
            void pushBackEvent(MIDIEvent *pEvent);

            void destroyAllEvents();

            MIDIEventListIterator begin()
            {
                return mEventList.begin();
            }

            MIDIEventListConstIterator begin() const
            {
                return mEventList.begin();
            }

            MIDIEventListIterator end()
            {
                return mEventList.end();
            }

            MIDIEventListConstIterator end() const
            {
                return mEventList.end();
            }

            ~MIDITrack();

        private:
            std::string mName;
            byte mChannel;
            byte mInstrument;
            MIDIEventList mEventList;
            bool mHasNotes;
    };

    typedef std::vector<MIDITrack*> MIDITrackVector;
    typedef MIDITrackVector::iterator MIDITrackVectorIterator;
    typedef MIDITrackVector::const_iterator MIDITrackVectorConstIterator;
}

#endif
